/**************************************************************************
* This file is part of Hawkengine.
**
* Hawkengine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
**
* Hawkengine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
**
* You should have received a copy of the GNU Lesser General Public License
* along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#ifndef _SOUND_H_
#define _SOUND_H_

/**************************************************************************
* Dependencies
**************************************************************************/
#include "engine/common.h"
 
/**************************************************************************
* Preprocessing
**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

#define MAX_SOURCES 4

/**************************************************************************
* Types
**************************************************************************/
typedef struct
{
  UINT buffer_handle;
  UINT source_handles[MAX_SOURCES];
  UINT source_count;
  float source_offsets[MAX_SOURCES][3];
  void* user_data;
} sound_type;

typedef void (*sound_delete_func_type)(sound_type* sound);
typedef BOOL (*sound_generate_func_type)(const file_data_type* file_data, sound_type* sound);
typedef void (*sound_init_func_type)(void);
typedef BOOL (*sound_is_playing_func_type)(const sound_type* sound);
typedef BOOL (*sound_pause_func_type)(const sound_type* sound);
typedef BOOL (*sound_play_at_func_type)(const sound_type* sound, const float location[3], BOOL loop);
typedef BOOL (*sound_set_listener_func_type)(const camera_type* camera);
typedef BOOL (*sound_stop_func_type)(const sound_type* sound);
typedef void (*sound_uninit_func_type)(void);

/**************************************************************************
* Variables
**************************************************************************/
extern UCHAR sound_volume;
extern sound_type sound_applause;
extern sound_type sound_boo;
extern sound_type sound_bubble;
extern sound_type sound_cheering;
extern sound_type sound_click;

extern sound_delete_func_type sound_delete_func;
extern sound_generate_func_type sound_generate_func;
extern sound_generate_func_type sound_generate_ambient_func;
extern sound_init_func_type sound_init_func;
extern sound_is_playing_func_type sound_is_playing_func;
extern sound_pause_func_type sound_pause_func;
extern sound_play_at_func_type sound_play_at_func;
extern sound_set_listener_func_type sound_set_listener_func;
extern sound_stop_func_type sound_stop_func;
extern sound_uninit_func_type sound_uninit_func;

/**************************************************************************
* Static Variables
**************************************************************************/

/**************************************************************************
* Function Prototypes
**************************************************************************/
BOOL sound_generate(const file_data_type* file_data, sound_type* sound);
BOOL sound_generate_ambient(const file_data_type* file_data, sound_type* sound);
void sound_init(void);
BOOL sound_is_playing(const sound_type* sound);
BOOL sound_play(const sound_type* sound, BOOL loop);
BOOL sound_play_at(const sound_type* sound, const float location[3], BOOL loop);
BOOL sound_pause(const sound_type* sound);
void sound_prepare_environment(void);
void sound_schedule(const sound_type* sound, float delay);
BOOL sound_set_listener(const camera_type* camera);
BOOL sound_stop(const sound_type* sound);
void sound_toggle(void);
void sound_uninit(void);
void sound_update(float secs);

/**************************************************************************
* Function Implementations
**************************************************************************/


#ifdef __cplusplus
}
#endif

#endif
